package com.example.combinebitmap;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import com.boyuan.huijiaoyu.AddGroup;
import com.boyuan.huijiaoyu.ColorHolderApplication;
import com.boyuan.huijiaoyu.R;
import com.boyuan.huijiaoyu.RoundImageView;
import com.easemob.EMCallBack;
import com.easemob.EMValueCallBack;
import com.easemob.chat.EMChatManager;
import com.easemob.chat.EMGroupManager;
import com.easemob.util.HanziToPinyin;
import com.example.contactfragment.ContactGroupService;
import com.example.contactfragment.ContactService;
import com.example.huanxin.ChatActivity;
import com.example.huanxin.Constant;
import com.example.huanxin.more.HXSDKHelper;
import com.example.huanxin.more.User2;
import com.example.huanxin.more.UserDao;
import com.example.newfragment.DetailPerson;
import com.magicsoft.app.helper.SharePreferenceHelper;
import com.magicsoft.app.helper.ToastHelper;
import com.magicsoft.app.wcf.listener.GetMultilParamsListener;
import com.magicsoft.app.wcf.listener.GetOneRecordListener;
import com.magicsoft.app.wcf.listener.PostRecordResponseListener;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.ttcaca.cas.android.client.utils.Helper;
import android.media.ThumbnailUtils;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.DialogInterface.OnCancelListener;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.CompoundButton.OnCheckedChangeListener;

public class NewGroupActivity extends Activity implements OnClickListener{
	
	private ContactGroupService contactgroupService;
	String user;
	private TextView groupname;
	private ListView listview;
	private ContactService contactService;
	private String id;
	private ArrayList<String> uidlist = new ArrayList<String>();
	private ArrayList<DetailPerson> friendlist = new ArrayList<DetailPerson>();
	private ArrayList<DetailPerson> personlist = new ArrayList<DetailPerson>();
	private ArrayList<String> addlist = new ArrayList<String>();
	private ArrayList<String> mobilelist = new ArrayList<String>();
	private ArrayList<String> namelist = new ArrayList<String>();
	private ArrayList<String> groupnamelist = new ArrayList<String>();
	private ArrayList<String> groupnamelist2 = new ArrayList<String>();
	boolean isrequestok = false;
	boolean isok = false;
	private String personname;
	private MyAdapter adapter;
	private boolean progressShow;
	private AddGroup group2;
	private String members1;
	ImageLoader imageLoader = ImageLoader.getInstance();
	private DisplayImageOptions options;
	private String mobile;
	private String usermobile;
	private String newmembers1;
	private RelativeLayout layNew;
	private TextView tvok;
//	private ArrayList<Bitmap> bitmaplist = new ArrayList<Bitmap>();
	HashMap<String, Bitmap> bitmaplist = new HashMap<String, Bitmap>();
	private ArrayList<String> urllist = new ArrayList<String>();
	private ArrayList<String> addurllist = new ArrayList<String>();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_new_group);
		personname = getIntent().getStringExtra("name");
		mobile = getIntent().getStringExtra("mobile");
		contactID = getIntent().getStringExtra("contactID");
		SharedPreferences sp = this.getSharedPreferences("a.xml", 0);
		user = sp.getString("realname", "");
		usermobile = sp.getString("username", "");
		groupnamelist.add(user);
		groupnamelist.add(personname);
		groupnamelist2.add(usermobile);
		groupnamelist2.add(mobile);
		id = sp.getString("id", "");
		addurllist.add(com.magicsoft.constant.Constant.photourl + id);
		ImageAsynTask imageAsynTask = new ImageAsynTask(com.magicsoft.constant.Constant.photourl + id);
		imageAsynTask.execute(com.magicsoft.constant.Constant.photourl + id);
		addurllist.add(com.magicsoft.constant.Constant.photourl + contactID);
		urllist.add(id);
		urllist.add(contactID);
		getMyFriendCache();
//		getFrequentContacts();
		initUI();
	}
	private List<MyBitmapEntity> mEntityList;
	private String contactID;
	private void initGroupPhoto(String groupid) {
		if(addurllist.size()>2 && addurllist.size()<10){
			mEntityList = getBitmapEntitys(addurllist.size());
			Bitmap[] mBitmaps = {
					ThumbnailUtils.extractThumbnail(bitmaplist.get(com.magicsoft.constant.Constant.photourl + id), (int) mEntityList
							.get(0).width, (int) mEntityList.get(0).width),
					ThumbnailUtils.extractThumbnail(BitmapUtil.getScaleBitmap(
							getResources(), R.drawable.btn_back), (int) mEntityList
							.get(0).width, (int) mEntityList.get(0).width),
					ThumbnailUtils.extractThumbnail(BitmapUtil.getScaleBitmap(
							getResources(), R.drawable.btn_back), (int) mEntityList
							.get(0).width, (int) mEntityList.get(0).width),
					ThumbnailUtils.extractThumbnail(BitmapUtil.getScaleBitmap(
							getResources(), R.drawable.btn_back), (int) mEntityList
							.get(0).width, (int) mEntityList.get(0).width),
					ThumbnailUtils.extractThumbnail(BitmapUtil.getScaleBitmap(
							getResources(), R.drawable.btn_back), (int) mEntityList
							.get(0).width, (int) mEntityList.get(0).width),
					ThumbnailUtils.extractThumbnail(BitmapUtil.getScaleBitmap(
							getResources(), R.drawable.btn_back), (int) mEntityList
							.get(0).width, (int) mEntityList.get(0).width),
					ThumbnailUtils.extractThumbnail(BitmapUtil.getScaleBitmap(
							getResources(), R.drawable.btn_back), (int) mEntityList
							.get(0).width, (int) mEntityList.get(0).width) ,
					ThumbnailUtils.extractThumbnail(BitmapUtil.getScaleBitmap(
							getResources(), R.drawable.btn_back), (int) mEntityList
							.get(0).width, (int) mEntityList.get(0).width),
					ThumbnailUtils.extractThumbnail(BitmapUtil.getScaleBitmap(
							getResources(), R.drawable.btn_back), (int) mEntityList
							.get(0).width, (int) mEntityList.get(0).width) };
			for (int i = 1; i < addurllist.size(); i++) {
				for (int j = 0; j < uidlist.size(); j++) {
					if(addurllist.get(i).contains(uidlist.get(j))){
						mBitmaps[i] = ThumbnailUtils.extractThumbnail(bitmaplist.get(com.magicsoft.constant.Constant.photourl + uidlist.get(j)), (int) mEntityList
								.get(0).width, (int) mEntityList.get(0).width);
					}
				}
			}
			Bitmap combineBitmap = BitmapUtil.getCombineBitmaps(mEntityList,mBitmaps);
			shangchuan(combineBitmap, groupid);
		}
	}
	
	public void shangchuan(Bitmap bitmap, String groupid){
		
		File fileName = null;
		fileName = new File(Environment.getExternalStorageDirectory(), groupid);
		try {
			BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileName));
			bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
			bos.flush();
			bos.close();
			Helper.uploadHeadIcon(com.magicsoft.constant.Constant.photourl, groupid, fileName , new PostRecordResponseListener() {
				
				@Override
				public void onFinish(String succString) {
					Log.e("succString", succString);
				}
				
				@Override
				public void onFailed(String failString) {
					
				}
			});
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	private void initUI() {
		groupname = (TextView) findViewById(R.id.edit_groupname);
		tvok = (TextView) findViewById(R.id.tv_newgroupok);
		groupname.setEnabled(false);
		groupname.setText(groupnamelist.toString().trim());
		findViewById(R.id.lay_back).setOnClickListener(this);
		layNew = (RelativeLayout) findViewById(R.id.lay_save);
		layNew.setOnClickListener(this);
//		for (int i = 0; i < friendlist.size(); i++) {
//			mobilelist.add(friendlist.get(i).getMobile());
//			namelist.add(friendlist.get(i).getRealname());
//		}
		listview = (ListView) findViewById(R.id.listView1);
		adapter = new MyAdapter();
		listview.setAdapter(adapter);
		listview.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View view, int arg2,
					long arg3) {
//				if(isrequestok == true){
					CheckBox cb1 = (CheckBox) view.findViewById(R.id.checkBox1);
					cb1.toggle();
//				}else{
//					Toast.makeText(NewGroupActivity.this, "网络异常", Toast.LENGTH_SHORT).show();
//				}
			}
		});
	}
	
	class ImageAsynTask extends AsyncTask<String, Void, Bitmap>{

		ImageView image;
		String str;
		
		public ImageAsynTask(ImageView image, String url){
			this.image = image;
			this.str = url;
		}
		
		public ImageAsynTask(String url){
			this.str = url;
		}
		
		@Override
		protected Bitmap doInBackground(String... params) {
			Bitmap bitmap = null;
			String path = params[0];
			try {
				URL url = new URL(path);
				URLConnection openConnection = url.openConnection();
				InputStream inputStream = openConnection.getInputStream();
//				bitmap = BitmapFactory.decodeStream(inputStream);
				
				Options options2 = new BitmapFactory.Options();
				options2.inSampleSize = 4;
				bitmap = BitmapFactory.decodeStream(inputStream, null, options2);
				
				bitmaplist.put(str, bitmap);
			} catch (MalformedURLException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return bitmap;
		}
		
		@Override
		protected void onPostExecute(Bitmap result) {
			if(image != null){
				image.setImageBitmap(result);
			}
			super.onPostExecute(result);
		}
	}
	
	
	class MyAdapter extends BaseAdapter{

		@Override
		public int getCount() {
//			return mobilelist.size();
			return namelist.size();
		}

		@Override
		public Object getItem(int arg0) {
			return null;
		}

		@Override
		public long getItemId(int arg0) {
			return 0;
		}

		@Override
		public View getView(final int arg0, View arg1, ViewGroup arg2) {
			View inflate = getLayoutInflater().inflate(R.layout.list_friend, null);
			final CheckBox cb = (CheckBox) inflate.findViewById(R.id.checkBox1);
			final TextView tv = (TextView) inflate.findViewById(R.id.tvname);
			RoundImageView photo = (RoundImageView) inflate.findViewById(R.id.imag_photo);
			options = new DisplayImageOptions.Builder()
			.showImageOnLoading(R.drawable.default_header)
			.showImageForEmptyUri(R.drawable.default_header)
			.showImageOnFail(R.drawable.default_header).cacheInMemory(true)
			.cacheOnDisc(true).considerExifParams(true)
			.build();
//			String uri = com.magicsoft.constant.Constant.photourl + mobilelist.get(arg0);
			String uri = com.magicsoft.constant.Constant.photourl + uidlist.get(arg0);
//			imageLoader.displayImage(uri, photo);
//			Bitmap bitmap = ((BitmapDrawable)photo.getDrawable()).getBitmap();
//			bitmaplist.put(uri, bitmap);
			Bitmap bitmap = bitmaplist.get(uri);
			if(bitmap != null){
				photo.setImageBitmap(bitmap);
			}else{
				ImageAsynTask imageAsynTask = new ImageAsynTask(photo, uri);
				imageAsynTask.execute(uri);
			}
			
//			tv.setText(mobilelist.get(arg0));
			tv.setText(namelist.get(arg0));
			if(personname.equals(tv.getText().toString().trim())){
				cb.setChecked(true);
			}
			
			cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
				
				@Override
				public void onCheckedChanged(CompoundButton compoundButton, boolean ischecked) {
					if(personname.equals(tv.getText().toString().trim())){
						ischecked = true;
						cb.setChecked(true);
					}
					if(ischecked){
						if(personname.equals(tv.getText().toString().trim())){
						}else{
							addlist.add(tv.getText().toString().trim());
							if(addlist.size()>0){
								layNew.setBackgroundColor(Color.parseColor("#3DB516"));
								tvok.setText("确定("+addlist.size()+")");
							}else{
								layNew.setBackgroundColor(Color.parseColor("#256816"));
								tvok.setText("确定");
							}
							groupnamelist.add(tv.getText().toString().trim());
							groupnamelist2.add(mobilelist.get(arg0));
							groupname.setText(groupnamelist.toString().trim());
							urllist.add(uidlist.get(arg0));
							addurllist.add(com.magicsoft.constant.Constant.photourl + uidlist.get(arg0));
						}
					}else{
						if(personname.equals(tv.getText().toString().trim())){
							
						}else{
							addlist.remove(tv.getText().toString().trim());
							if(addlist.size()>0){
								layNew.setBackgroundColor(Color.parseColor("#3DB516"));
								tvok.setText("确定("+addlist.size()+")");
							}else{
								layNew.setBackgroundColor(Color.parseColor("#256816"));
								tvok.setText("确定");
							}
							groupnamelist.remove(tv.getText().toString().trim());
							groupnamelist2.remove(mobilelist.get(arg0));
							urllist.remove(uidlist.get(arg0));
							groupname.setText(groupnamelist.toString().trim());
						}
					}
				}
			});
			return inflate;
		}
		
	}

	//获取我的好友缓存
	private void getMyFriendCache() {
		friendlist.clear();
		mobilelist.clear();
		uidlist.clear();
		namelist.clear();
		ArrayList<DetailPerson> myfriendList = SharePreferenceHelper.getContactFrindList(NewGroupActivity.this, id);
		if (myfriendList.size() > 0) {
			friendlist.addAll(myfriendList);
			for (int i = 0; i < friendlist.size(); i++) {
				mobilelist.add(friendlist.get(i).getMobile());
				uidlist.add(friendlist.get(i).getUid());
				namelist.add(friendlist.get(i).getRealname());
			}
		}else{
			Toast.makeText(NewGroupActivity.this, "您还没有好友！", Toast.LENGTH_SHORT).show();
			finish();
		}
	}
	
	/**
	 * 获取常用联系人
	 */
	private void getFrequentContacts() {

		if (contactService == null) {
			contactService = new ContactService(this);
		}
		contactService.getFrequentContacts(id,
				new GetOneRecordListener<List<DetailPerson>>() {

			@Override
			public void onFinish(List<DetailPerson> data) {
				friendlist.clear();
				mobilelist.clear();
				namelist.clear();
				uidlist.clear();
				if (data != null && data.size() > 0) {
					friendlist.addAll(data);
					for (int i = 0; i < friendlist.size(); i++) {
						mobilelist.add(friendlist.get(i).getMobile());
						namelist.add(friendlist.get(i).getRealname());
						uidlist.add(friendlist.get(i).getUid());
					}
					SharePreferenceHelper.saveMyFrindList(NewGroupActivity.this, id, data);
					isrequestok = true;
				}else{
					Toast.makeText(NewGroupActivity.this, "您还没有好友！", Toast.LENGTH_SHORT).show();
					finish();
				}
				adapter.notifyDataSetChanged();
			}

			@Override
			public void onFailed(String Message) {
				ToastHelper.showMsg(NewGroupActivity.this, Message, false);
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.new_group, menu);
		return true;
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.lay_back:
			finish();
			break;
		case R.id.lay_save:
			String groupname1 = groupname.getText().toString().trim();
			String newgroupname1 = groupnamelist2.toString();
			String members = groupname1.substring(1, groupname1.length()-1);
			String newmembers = newgroupname1.substring(1, newgroupname1.length()-1);
			members1 = members.replaceAll(" ", "");
			newmembers1 = newmembers.replace(" ", "");
			if(addlist.size() > 0){
				newGroup();
			}else{
				Toast.makeText(NewGroupActivity.this, "请选择要添加的好友！",Toast.LENGTH_SHORT).show();
			}
			break;
		default:
			break;
		}
	}

	private void newGroup() {
		if (contactgroupService == null) {
			contactgroupService = new ContactGroupService(this);
		}
		
		contactgroupService.newGroup(usermobile, members1, "normal", false, "200", newmembers1, new GetMultilParamsListener() {

			@Override
			public void onFinish(Object... params) {
				if(params!=null){
					group2 = (AddGroup) params[0];
					initGroupPhoto(group2.getGroupid());
					chat();
					finish();
				}
			}
			
			@Override
			public void onFailed(String Message) {
				
			}
		});
	}
	
	
	private void chat() {

		progressShow = true;
		final ProgressDialog pd = new ProgressDialog(this);
		pd.setCanceledOnTouchOutside(false);
		pd.setOnCancelListener(new OnCancelListener() {

			@Override
			public void onCancel(DialogInterface dialog) {
				progressShow = false;
			}
		});
		pd.setMessage(getString(R.string.Is_landing));
		pd.show();

		final long start = System.currentTimeMillis();
		SharedPreferences sp = getSharedPreferences("a.xml", 0);
		String username = sp.getString("username", "18030095903");
		String mima = "" + username.substring(5, username.length());

		EMChatManager.getInstance().login(username, mima, new EMCallBack() {

			@Override
			public void onSuccess() {
				if (!progressShow) {
					return;
				}

				try {
					// ** manually load all local groups and
					EMGroupManager.getInstance().loadAllGroups();
					EMChatManager.getInstance().loadAllConversations();
					initializeContacts();
					asyncFetchContactsFromServer();
				} catch (Exception e) {
					e.printStackTrace();
					runOnUiThread(new Runnable() {
						public void run() {
							pd.dismiss();
							ColorHolderApplication.getInstance().logout(null);
							Toast.makeText(getApplicationContext(),
									R.string.login_failure_failed, 1).show();
						}
					});
					return;
				}
				boolean updatenick = EMChatManager.getInstance()
						.updateCurrentUserNick(
								ColorHolderApplication.currentUserNick.trim());
				if (!updatenick) {
				}
				if (!isFinishing() && pd.isShowing()) {
					pd.dismiss();
				}

				Intent intent = new Intent(NewGroupActivity.this,
						ChatActivity.class);
				intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP);
				intent.putExtra("groupId", group2.getGroupid());
				intent.putExtra("groupName", members1);
				startActivityForResult(intent, 0);
				finish();
			}

			private void asyncFetchContactsFromServer() {

				HXSDKHelper.getInstance().asyncFetchContactsFromServer(
						new EMValueCallBack<List<String>>() {

							@Override
							public void onSuccess(List<String> usernames) {
								Context context = HXSDKHelper.getInstance().getAppContext();

								Map<String, User2> userlist = new HashMap<String, User2>();
								for (String username : usernames) {
									User2 user = new User2();
									user.setUsername(username);
									setUserHearder(username, user);
									userlist.put(username, user);
								}
								User2 newFriends = new User2();
								newFriends.setUsername(Constant.NEW_FRIENDS_USERNAME);
								String strChat = context.getString(R.string.Application_and_notify);
								newFriends.setNick(strChat);

								userlist.put(Constant.NEW_FRIENDS_USERNAME, newFriends);
								User2 groupUser = new User2();
								String strGroup = context.getString(R.string.group_chat);
								groupUser.setUsername(Constant.GROUP_USERNAME);
								groupUser.setNick(strGroup);
								groupUser.setHeader("");
								userlist.put(Constant.GROUP_USERNAME, groupUser);

								User2 chatRoomItem = new User2();
								String strChatRoom = context
										.getString(R.string.chat_room);
								chatRoomItem.setUsername(Constant.CHAT_ROOM);
								chatRoomItem.setNick(strChatRoom);
								chatRoomItem.setHeader("");
								userlist.put(Constant.CHAT_ROOM, chatRoomItem);

								ColorHolderApplication.getInstance()
										.setContactList(userlist);
								UserDao dao = new UserDao(context);
								List<User2> users = new ArrayList<User2>(
										userlist.values());
								dao.saveContactList(users);

								HXSDKHelper.getInstance()
										.notifyContactsSyncListener(true);

								if (HXSDKHelper.getInstance()
										.isGroupsSyncedWithServer()) {
									HXSDKHelper.getInstance()
											.notifyForRecevingEvents();
								}

							}

							@Override
							public void onError(int error, String errorMsg) {
								HXSDKHelper.getInstance()
										.notifyContactsSyncListener(false);
							}

						});

			}

			private void setUserHearder(String username, User2 user) {
				String headerName = null;
				if (!TextUtils.isEmpty(user.getNick())) {
					headerName = user.getNick();
				} else {
					headerName = user.getUsername();
				}
				if (username.equals(Constant.NEW_FRIENDS_USERNAME)) {
					user.setHeader("");
				} else if (Character.isDigit(headerName.charAt(0))) {
					user.setHeader("#");
				} else {
					user.setHeader(HanziToPinyin.getInstance()
							.get(headerName.substring(0, 1)).get(0).target
							.substring(0, 1).toUpperCase());
					char header = user.getHeader().toLowerCase().charAt(0);
					if (header < 'a' || header > 'z') {
						user.setHeader("#");
					}
				}
			}

			private void initializeContacts() {
				Map<String, User2> userlist = new HashMap<String, User2>();
				User2 newFriends = new User2();
				newFriends.setUsername(Constant.NEW_FRIENDS_USERNAME);
				String strChat = getResources().getString(
						R.string.Application_and_notify);
				newFriends.setNick(strChat);

				userlist.put(Constant.NEW_FRIENDS_USERNAME, newFriends);
				User2 groupUser = new User2();
				String strGroup = getResources().getString(R.string.group_chat);
				groupUser.setUsername(Constant.GROUP_USERNAME);
				groupUser.setNick(strGroup);
				groupUser.setHeader("");
				userlist.put(Constant.GROUP_USERNAME, groupUser);
				ColorHolderApplication.getInstance().setContactList(userlist);
				UserDao dao = new UserDao(NewGroupActivity.this);
				List<User2> users = new ArrayList<User2>(userlist.values());
				dao.saveContactList(users);

			}

			@Override
			public void onProgress(int progress, String status) {
			}

			@Override
			public void onError(final int code, final String message) {
				if (!progressShow) {
					return;
				}
				runOnUiThread(new Runnable() {
					public void run() {
						pd.dismiss();
					}
				});
			}
		});
	}
	
	public static class MyBitmapEntity {
		float x;
		float y;
		float width;
		float height;
		static int devide = 1;
		int index = -1;

		@Override
		public String toString() {
			return "MyBitmap [x=" + x + ", y=" + y + ", width=" + width
					+ ", height=" + height + ", devide=" + devide + ", index="
					+ index + "]";
		}
	}

	private List<MyBitmapEntity> getBitmapEntitys(int count) {
		List<MyBitmapEntity> mList = new LinkedList<NewGroupActivity.MyBitmapEntity>();
		String value = PropertiesUtil.readData(this, String.valueOf(count),
				R.raw.data);
		LogUtil.d("value=>" + value);
		String[] arr1 = value.split(";");
		int length = arr1.length;
		for (int i = 0; i < length; i++) {
			String content = arr1[i];
			String[] arr2 = content.split(",");
			MyBitmapEntity entity = null;
			for (int j = 0; j < arr2.length; j++) {
				entity = new MyBitmapEntity();
				entity.x = Float.valueOf(arr2[0]);
				entity.y = Float.valueOf(arr2[1]);
				entity.width = Float.valueOf(arr2[2]);
				entity.height = Float.valueOf(arr2[3]);
			}
			mList.add(entity);
		}
		return mList;
	}

	
}
